// hospital/pages/registration/registration.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    departmentList: [],
    user: ''
  },

  toDetail(e) {
    var obj = e.currentTarget.dataset.obj

    console.log(obj);

    wx.navigateTo({
      url: '/hospital/pages/registrationDetails/registrationDetails?departmant=' + JSON.stringify(obj),
    })
  },
  toHistory() {
    wx.navigateTo({
      url: '/hospital/pages/registrationHistory/registrationHistory',
    })
  },



  getList() {
    var url = app.globalData.url + "doctor/listDepartment",
      that = this;
    wx.showLoading({
      title: '',
    })
    app.wxRequest(url, {}, res => {
        console.log(res);
        if (res.flag) {
          wx.hideLoading()
          var datas = res.data
          datas.forEach(item => {
            item.imgUrl = `/hospital/img/${item.departmentId}.png`
          })
          that.setData({
            departmentList: datas
          })
          console.log(that.data);
        }
      },
      err => {
        console.log(err);
      })


  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getList()
    this.setData({
      user: app.globalData.user
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})